package com.wsz.user.service.impl;

import com.wsz.user.consumer.WebSocketServer;
import com.wsz.user.service.ReceiveBotMoveService;
import com.wsz.user.utils.Game;
import org.springframework.stereotype.Service;

@Service
public class ReceiveBotMoveServiceImpl implements ReceiveBotMoveService {

    @Override
    public String receiveBotMove(String userId, Integer direction) {
        if(WebSocketServer.users.get(userId) != null){

            Game game = WebSocketServer.users.get(userId).game;

            if(game != null){
                if(game.getPlayerA().getId().equals(userId)){
                    game.setNextStepA(direction);
                }else if(game.getPlayerB().getId().equals(userId)){
                    game.setNextStepB(direction);
                }
            }
        }
        return null;
    }
}
